package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

@Mapper
public interface UserMapper {

    /**
     * 根据openId查找User
     * @param openId
     * @return
     */
    @Select("select id, openid, name, phone, sex, id_number, avatar, create_time from user where openid = #{openId}")
    User getUserByOpenId(String openId);

    void saveUser(User user);

    /**
     * 通过id查询用户
     * @param userId
     * @return
     */
    @Select("select * from user where id = #{userId}")
    User getById(Long userId);

    /**
     * 获取用户数量
     * @param beginTime
     * @param endTime
     * @return
     */
    Integer getUserCountByTime(LocalDateTime beginTime, LocalDateTime endTime);
}
